﻿namespace Contoso.ActiveDirectory {

    #region Usings
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks; 
    #endregion

    [Serializable]
    public class CustomAttributes : ICustomAttributes {

        #region Members
        public static readonly string[] AttributesToGet;

        public IReadOnlyList<string> MIExtensionAttribute1 { get; private set; }
        public IReadOnlyList<string> MIExtensionAttribute2 { get; private set; }
        public IReadOnlyList<string> MIExtensionAttribute3 { get; private set; }
        #endregion

        #region Constructors
        static CustomAttributes() {
            AttributesToGet = new string[] 
            {
                "miExtensionAttribute1",
                "miExtensionAttribute2",
                "miExtensionAttribute3"
            };
        }
        public CustomAttributes() {
            this.MIExtensionAttribute1 = new List<string>();
            this.MIExtensionAttribute2 = new List<string>();
            this.MIExtensionAttribute3 = new List<string>();
        } 
        #endregion

        #region Methods
        public void ProcessResults(Dictionary<string, object[]> attributes) {
            if (attributes.ContainsKey("miExtensionAttribute1")) this.MIExtensionAttribute1 = ADDataAccess.GetMultiValuedAttribute<string>("miExtensionAttribute1", attributes);
            if (attributes.ContainsKey("miExtensionAttribute2")) this.MIExtensionAttribute2 = ADDataAccess.GetMultiValuedAttribute<string>("miExtensionAttribute2", attributes);
            if (attributes.ContainsKey("miExtensionAttribute3")) this.MIExtensionAttribute3 = ADDataAccess.GetMultiValuedAttribute<string>("miExtensionAttribute3", attributes);
        } 
        #endregion
    }
}
